<template>
	<view>

		<view class="search_fixed">
			<mySearch :custom="true" :defList="searchList" @SearchEvent="SearchEvent" @ClearEvent="ClearEvent">
			</mySearch>
		</view>

		<mescroll-body @init="mescrollInit" @down="downCallback" :down="$gl.downOption" @up="upCallback"
			:up="$gl.upOption" :top="$gl.upOption.top">
			<uni-list v-for="(item,index) in list" :key="index">
				<uni-list-item :title="item.WorkMemo" :note="'创建人:' +item.Run_CreateUserName" :thumb="$gl.itemIcon"
					thumbSize="lg" :rightText="item.Run_CreateDate | formatDate" clickable @click="btnDetails(item)">
				</uni-list-item>
			</uni-list>
		</mescroll-body>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
				filter: {
					list: [],
				},
				searchList: [{
						key: "WorkMemo",
						text: "标题",
						value: ""
					},
					{
						key: "Run_CreateUserName",
						text: "创建人",
						value: ""
					},
					{
						key: "Run_CreateDate",
						text: "创建时间",
						value: ""
					}
				],
				listCode: "",
				api: Config.PlatformAPI + publicJs.Config.WorkFlowRun.GetMyTaskYBGroupList,
				WorkName: "",
			};
		},
		onLoad(option) {

			const getPageData = this.$gl.uDecode(option.pageData);

			this.WorkName = getPageData.WorkName;
		},
		onReady() {
			this.mescroll.triggerUpScroll();
		},
		methods: {
			upCallback(page) {
				this.loadData(page.num, page.size)
			},
			loadData(index, size) {
				let obj = {
					SiteID: Common.Const.Site.SiteID,
					WorkName: this.WorkName
				}
				this.$gl.loadMore(this, index, size, obj);
			},
			SearchEvent(e) {
				this.list = [];
				this.filter = e;
				this.mescroll.resetUpScroll()
			},
			ClearEvent(e) {
				this.list = [];
				this.filter.list = [];

				this.searchList = this.searchList.map(item => {
					return {
						key: item.key,
						text: item.text,
						value: ""
					}
				});

				this.mescroll.resetUpScroll()
			},
			btnDetails(param) {

				if (this.$gl.IsNullOrEmpty(param)) {
					this.$gl.toastFail("已办数据为空");
					return;
				}

				let pageData = {
					action: 'view',
					Key: param.Business_Key,
					Run_ID: param.Run_ID,
					SiteID: param.SiteID,
					title: param.WorkMemo,
				}

				const path = this.getPageUrl(param.PageUrl);

				this.$gl.setStorage(pageData, path);

			},
			getPageUrl(path) {
				let _path = "";
				if (!this.$gl.IsNullOrEmpty(path)) {
					_path = path.replace('/web', '/pages');
					_path = _path.split('.html')[0];
				}
				return _path;
			}

		}
	}
</script>

<style>
</style>
